home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / c_arr1a / frmc_arr.frm < prev    next >
Text File  |  1999-09-19  |  4KB  |  153 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "cArray Example"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton cmdSet 
  13.       Caption         =   "Set"
  14.       Height          =   495
  15.       Left            =   3360
  16.       TabIndex        =   6
  17.       Top             =   2280
  18.       Width           =   1215
  19.    End
  20.    Begin VB.CommandButton cmdGet 
  21.       Caption         =   "Get"
  22.       Height          =   495
  23.       Left            =   3360
  24.       TabIndex        =   5
  25.       Top             =   1680
  26.       Width           =   1215
  27.    End
  28.    Begin VB.CommandButton cmdDown 
  29.       Caption         =   "Down"
  30.       Height          =   495
  31.       Left            =   3240
  32.       TabIndex        =   4
  33.       Top             =   840
  34.       Width           =   975
  35.    End
  36.    Begin VB.CommandButton cmdUp 
  37.       Caption         =   "Up"
  38.       Height          =   495
  39.       Left            =   3240
  40.       TabIndex        =   3
  41.       Top             =   240
  42.       Width           =   975
  43.    End
  44.    Begin VB.CommandButton cmdRemove 
  45.       Caption         =   "Remove"
  46.       Height          =   375
  47.       Left            =   1680
  48.       TabIndex        =   2
  49.       Top             =   2280
  50.       Width           =   1215
  51.    End
  52.    Begin VB.CommandButton cmdAdd 
  53.       Caption         =   "Add"
  54.       Height          =   375
  55.       Left            =   120
  56.       TabIndex        =   1
  57.       Top             =   2280
  58.       Width           =   1335
  59.    End
  60.    Begin VB.ListBox lstArray 
  61.       Height          =   1815
  62.       Left            =   120
  63.       TabIndex        =   0
  64.       Top             =   120
  65.       Width           =   3015
  66.    End
  67. End
  68. Attribute VB_Name = "Form1"
  69. Attribute VB_GlobalNameSpace = False
  70. Attribute VB_Creatable = False
  71. Attribute VB_PredeclaredId = True
  72. Attribute VB_Exposed = False
  73. 'I didn't go to alot of trouble with this form, because
  74. 'I knew that you guys will be smart enough to figure
  75. 'out how the class work. Good luck.
  76.  
  77. Dim myA As c_Array
  78.  
  79. Private Sub cmdAdd_Click()
  80.     itemValue = InputBox("Enter Text")
  81.     Key = InputBox("Enter Key")
  82.     myA.Add itemValue, Key
  83.     Update
  84. End Sub
  85.  
  86. Private Sub cmdRemove_Click()
  87.     If MsgBox("Yes: Enter Key      No: Enter Index", vbYesNo) = vbYes Then
  88.         Key = InputBox("Enter key:", "Remove")
  89.         myA.Remove , Key
  90.       Else
  91.         Index = InputBox("Enter Index:", "Remove")
  92.         myA.Remove Index
  93.     End If
  94.  
  95.     Update
  96. End Sub
  97.  
  98. Private Sub cmdUp_Click()
  99.     
  100.     If lstArray.ListIndex = -1 Then
  101.         Beep
  102.         Exit Sub
  103.     End If
  104.     
  105.     myA.MoveUp lstArray.ListIndex + 1
  106.     Update
  107. End Sub
  108.  
  109. Private Sub cmdDown_Click()
  110.     If lstArray.ListIndex = -1 Then
  111.         Beep
  112.         Exit Sub
  113.     End If
  114.     myA.MoveDown lstArray.ListIndex + 1
  115.     Update
  116. End Sub
  117.  
  118. Private Sub cmdGet_Click()
  119.     If MsgBox("Yes: Enter Key      No: Enter Index", vbYesNo) = vbYes Then
  120.         Key = InputBox("Enter Key:")
  121.         MsgBox myA.Itemget(, Key)
  122.       Else
  123.         Index = InputBox("Enter Index:")
  124.         MsgBox myA.Itemget(Index)
  125.     End If
  126. End Sub
  127.  
  128. Private Sub cmdSet_Click()
  129.     If MsgBox("Yes: Enter Key     No: Enter Index", vbYesNo, "Set") = vbYes Then
  130.         Key = InputBox("Enter Key:", "Set")
  131.         newVal = InputBox("Enter new value:", "Set")
  132.         myA.Itemset newVal, , Key
  133.       Else
  134.         Index = InputBox("Enter Index", "Set")
  135.         newVal = InputBox("Enter new value:", "Set")
  136.         myA.Itemset newVal, Index
  137.     End If
  138.     
  139.     Update
  140. End Sub
  141.  
  142. Private Sub Form_Load()
  143.     Set myA = New c_Array
  144. End Sub
  145.  
  146. Function Update()
  147.     lstArray.Clear
  148.     For i = 1 To myA.Count
  149.         lstArray.AddItem myA.Itemget(i)
  150.     Next
  151. End Function
  152.  
  153.